/**
 * Created by zh.zhou on 2016/07/22
 * 1.用户登陆
 */

$(".sh-yh-phone-btn").click(function(e) {
	e.preventDefault();
	var phone = $('#phone').val();
	var pwd = $('#passward').val();
	if (phone == null || phone.length != 11) {
		alert("手机号码格式不正确");
		return;
	}
	if (pwd == null || pwd.length == 0) {
		alert("密码不能为空");
		return;
	}
	$.ajax({
		type: "post",
		dataType: "json",
		data: JSON.stringify({
			phone: phone,
			passward: pwd,
		}),
		url: "/data/api/login_json",
		timeout: 30000,
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			alert("登陆失败！" + textStatus);
		},
		success: function(data) {
			var obj = eval(data)
			console.log(obj);
			if(obj.success==true){
				alert("登陆成功!");
				window.location.href ="https://www.pgyer.com/PuAA"
			}else{
				alert(obj.data)
			}
		}
	});
});